package org.demo.kafka.consumer;

import lombok.extern.slf4j.Slf4j;
import org.demo.redis.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class KafkaConsumer {
    @Autowired
    private RedisUtils redisUtils;
    @KafkaListener(topics = "testDemo")
    public void onMessage(String message){
        String redisKey = "kafkaTest";
        redisUtils.set(redisKey,message+System.currentTimeMillis());
        //获取消息进行逻辑处理，自定义
        log.info("message is:"+message+System.currentTimeMillis());
    }
}
